var config = require('config-lite');

/**
 * 文件上传接口
 *
 * @param {HttpRequest} req 请求
 * @param {HttpResponse} res 响应
 */
exports.upload = function(req, res, next){
    var reqfile = req.file;
    var filename = reqfile.filename;
    var fileUrl = config.filePath + filename;
    return res.send_data({
        entities: [{
            file_url: fileUrl,
            filename: filename
        }]
    });
//   var file = new File({
//     creator: req.user.id,
//     filename: reqfile.filename,
//     filesize: reqfile.size
//   });
//   file.save(function(err, result){
//     if(err){
//       return console.log(err);
//     }
//     var return_data = _.pick(result, file_pick_arr);
//     return_data.download_url = config.download_url + return_data.id;
//     var user = _.pick(req.user, user_pick_arr);
//     return_data.creator = user;
//     return res.send_data({
//       entities: return_data
//     });
//   });
  // var _suffix = req.file.originalname.replace(/(.+)(\..+)/g, '$2');
};
